/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=C:\Dropbox\SVN\PM App Launcher\Include\Titler\CWI Title Creator.exe
Created_Date=1
Execution_Level=2
[VERSION]
Resource_Files=C:\Dropbox\SVN\PM App Launcher\Resource\TTL_icon.ico
Set_Version_Info=1
Company_Name=WSNH Apps
File_Description=Automatically generate object descriptions (for use in CWI, etc.) that meet CAPE, HCT and WD standards
File_Version=3.0.1.8
Inc_File_Version=1
Internal_Name=CWI Title Creator.exe
Legal_Copyright=WSNH Apps
Original_Filename=CWI Title Creator.exe
Product_Name=AutoHotkey_L
Product_Version=1.1.5.3
Set_AHK_Version=1
[ICONS]
Icon_1=C:\Dropbox\SVN\PM App Launcher\Resource\TTL_icon.ico

* * * Compile_AHK SETTINGS END * * *
*/

 
;_____________________________________________________________________
;---------------------------------------------------------------------
;	Title: CWI Title Creator
;---------------------------------------------------------------------
;	
;	A simple user interface that auto-generates descriptions that
;	comply with CAPE, Halliburton and WD standards for use as drawing
;	titles and/or CWI descriptions.
;
;	Depends on <Excel Functions> included file, which allows the Titler
;	to automatically insert entries into the Mandrels and Clamps 
;	Excel databases.
;
;	(see TTL_ScreenShot.png)
;
;	Group: About
;		General script file information
;
;		- *Written By:* 	Sam Tehven
;		- *Last Modified:*	12/12/2011
;---------------------------------------------------------------------
 #SingleInstance, force
 SetTitleMatchMode, 2
;_____________________________________________________________________
;---------------------------------------------------------------------	

MouseGetPos, xposition, yposition
XL := Excel_Get()
	
	
		
	

;==========================================================================================
;
;                                 GLOBAL VARIABLES & SETTINGS
;
;==========================================================================================
	
	EPub 		:= "\\corp.halliburton.com\team\WD\Business Development and Technology\General\Engineering Public"
	
	TitlerInfo	:= Epub "\PM App Launcher\Titler\TitlerInfo.ini"
	
	
	
	;_________________________
	; 		GET TITLER VERSION
	;
		IniRead, Titler_Version, %epub%\PM App Launcher\versionCheck.ini, CWI Title Creator, version, Error



;=================================================================
;    GET THE FILE VERSION TO DISPLAY & SET TRAY ICON (IF COMPILED)
;=================================================================
	if (A_IsCompiled){	

	;____________________________________________
	; 		SET TRAY ICON FROM COMPILED RESOURCES
	;
		Menu, tray, icon, %A_ScriptFullPath%, -159
	
	}
	
	


;__________________________________________________________________________________________________________
;____________________________________________GUI CONTROL CHANGES___________________________________________

	;SPLASH IMAGE SETTINGS
		splash = w500 B1 CT000000 CWFFFFFF

	;GUI AND TAB CHANGES
		GuiWidth := 220
		GuiHeight := 705
		cGuiHeight := 535
		tGuiHeight := 520
		ClampTabH := 520
		GuiDrawingH := 345
	
	;CHEM NOT CHECKED
		TabH := 705
		Group1H := 340
		Group2Y := 400
		Group2H := 240
		ChemY := 366
		BomY := 645
		MandrelY := 645
		96Y := 675
		93Y := 675
		92Y := 675
	
	;CHEM CHECKED
		cTabH := 535
		cGroup1H := 270
		cGroup2Y := 330
		cGroup2H := 142
		cChemY := 295
		cBomY := 475
		cMandrelY := 475
		c96Y := 505
		c93Y := 505
		c92Y := 505
	
	;CLAMP DRAWING
		DDrawingY := 276
		DGroupC2H := 226
		DButtonY := 280
		PDrawingY := 331
		PGroupC2H := 335
		PButtonY := 488
		DButtonY := 315
	
;_______________________________________________________________________
;______________THREAD LIST AND COUNT__________________________________

	;THREAD TYPES AND COUNT
		loop
		{
			IniRead, temp, %TitlerInfo%, THREADTYPES, %A_Index%
			if(temp = "" or temp = "ERROR")
				break
			ThreadTypes := ThreadTypes = "" ? temp : ThreadTypes "|" temp
			ThreadNum := A_Index
		}
	
;________________________________________________________________________
;_______________MATERIAL LIST AND COUNT________________________________
	
	;MATERIAL TYPES AND COUNT
		loop
		{
			IniRead, temp, %TitlerInfo%, THEMATERIALS, %A_Index%
			if(temp = "" or temp = "ERROR")
				break
			TheMaterials := TheMaterials = "" ? temp : TheMaterials "|" temp
			MaterialNum := A_Index
		}
		
;________________________________________________________________________
;_______________PIPE SIZES AND COUNT________________________________
	
	;PIPE SIZES AND COUNT
		loop
		{
			IniRead, temp, %TitlerInfo%, PIPESIZES, %A_Index%
			if(temp = "" or temp = "ERROR")
				break
			PipeSizes := PipeSizes = "" ? temp : PipeSizes "|" temp
			PipeSizeNum := A_Index
		}

;________________________________________________________________________
;____________MONITOR SETUP ____________________________________________

	;~ sysget, numMons, monitorcount
	;~ sysget, leftMon1, Monitor  
	;~ leftMon := leftMon1Right    ; Size of left monitor
	;~ if numMons>1     ;Detected multiple monitors (assume 2)
	;~ {
		;~ sysget, totalMon, Monitor, 2    ; totalMonRight = total (combined) size of monitors
		;~ rightMon := totalMonRight - leftMon      ;Size of right monitor
		;~ if rightMon < 0     ;Left and right monitors are reverse referenced as 2 and 1
		;~ {
			;~ leftMon:=leftMon+rightMon
			;~ rightMon:=rightmon*-1
		;~ }
	;~ }
	;~ rightMonC := leftMon + (rightMon/2)      ;Center of RIGHT monitor
	;~ leftMonC := leftMon / 2        ;Center of LEFT monitor

;_______________________________________________________________________
;____________GUI CONTROL SETUP________________________________________

	Gui, Font, s9 cblack w700
	
	Gui, Add, Tab2, x0 y0 w220 h%TabH% Choose1 gTheTab vLastTab, MANDREL|CLAMP
	
	Gui, Tab, 1
	
	Gui, Font, s11 cblack w400
	Gui, Add, Text, x15 y30 w75 h25 Section, PART NUM
	Gui, Add, edit, xs+80 ys-5 w85 h25 vPartNum gMPartNum Uppercase, 9290-
	
	Gui, Font, w700
	Gui, Add, GroupBox, xs-10 yp+30 w210 h%Group1H% Section, MANDREL PROPERTIES
	
	;_____________________________________________________________________
	; 		ACCOUNT FOR POSSIBILITY OF %PIPESIZENUM% BEING 0 & CAUSING ERROR
		;
		if (PipeSizeNum < 1)
			PipeRowOption := ""
		else
			PipeRowOption := "r" PipeSizeNum

	Gui, Font, s11 cblack w400
	Gui, Add, Text, xs+10 yp+30 w75 h25, DIAMETER
	Gui, Add, DropDownList, xp+80 yp-5 w87 h21 %PipeRowOption% vMandrelDiameter gMDiameter, %PipeSizes%
	Gui, Add, Text, xp+92 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+27 w100 h25, WEIGHT
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vWeight gMWeight HWNDhEdit
	Gui, Add, Text, xp+80 yp+5 w30 h25, PPF
	
	Gui, Add, Text, xs+10 yp+28 w120 h25, THREAD
	
	;_____________________________________________________________________
	; 		ACCOUNT FOR POSSIBILITY OF %THREADNUM% BEING 0 & CAUSING ERROR
		;
		if (ThreadNum < 1)
			rowOption := ""
		else
			rowOption := "r" ThreadNum
	
	Gui, Add, ComboBox, xp+80 yp-5 w105 h25 %rowOption% vThreadType Uppercase gMThreads, %ThreadTypes%

	Gui, Font, w700
	Gui, Add, GroupBox, xs+5 yp+27 w195 h50, PROFILE
	Gui, Font, w400
	Gui, Add, Radio, xp+10 yp+20 w50 h25 vbxp gMProfile, B x P
	Gui, Add, Radio, xp+60 w50 h25 vbxb gMProfile, B x B
	Gui, Add, Radio, xp+60 w50 h25 vpxp gMProfile, P x P

	Gui, Add, Text, xs+10 yp+40 w100 h25, MATERIAL
	
	;_______________________________________________________________________
	; 		ACCOUNT FOR POSSIBILITY OF %MATERIALNUM% BEING 0 & CAUSING ERROR
	;
		if (MaterialNum < 1)
			row2Option := ""
		else
			row2Option := "r" MaterialNum
		
	Gui, Add, ComboBox, xp+80 yp-5 w105 h25 %row2Option% vMaterial gMMaterial Uppercase, %TheMaterials%
	
	Gui, Add, Text, xs+10 yp+32 w75 h25, YIELD
	Gui, Add, Edit, xp+80 yp-5 w91 h25 vYield gMYield number
	Gui, Add, Text, xp+96 yp+5 w10 h25, K
	
	Gui, Add, CheckBox, xs+10 yp+25 w100 h25 vByPass gMBypass, BY-PASS
	Gui, Add, CheckBox, yp+23 w150 h25 vTerm gMDMS, DUAL METAL SEAL
	Gui, Add, CheckBox, yp+23 w150 h25 vCoupling gMCoupling, COUPLING
	Gui, Add, CheckBox, yp+23 w150 h25 vFlowmeter gMFlowMeter, FLOWMETER
	Gui, Add, CheckBox, yp+23 w175 h25 vcheminj gMChem, CHEMICAL INJECTION

	Gui, Font, w700
	Gui, Add, GroupBox, xs yp+35 w210 h%Group2H% Section, GAUGE PROPERTIES
	
	Gui, Font, w400
	Gui, Add, Text, xs+10 yp+30 w130 h25, GAUGE FAMILY
	Gui, Add, DropDownList, xp+107 yp-5 w80 h25 R4 gMGFamily vGaugeFamily, ROC|ROC-S|ROC-D|ROC-L
	
	Gui, Add, Text, xs+10 yp+32 w130 h25, DIAMETER
	Gui, Add, DropDownList, xp+107 yp-5 w60 h25 R2 vGaugeDiameter gMGDiameter, 0.75|1.125
	Gui, Add, Text, xp+65 yp+5 w20 h25, IN
	
	Gui, Add, Text, xs+10 yp+27 w130 h25, GAUGE TYPE
	Gui, Add, DropDownList, xp+107 yp-5 w80 h25 R4 vGaugeType gMGType, SINGLE|DUAL|TRIPLE|QUAD

	Gui, Add, Text, xs+10 yp+32 w130 h25, PRESSURE
	Gui, Add, Edit, xp+107 yp-5 w66 h25 vPressure gMPressure number
	Gui, Add, Text, xp+71 yp+5 w10 h25, K
	
	Gui, Add, Text, xs+10 yp+28 w130 h25, TEMPERATURE
	Gui, Add, Edit, xp+107 yp-5 w66 h25 vTemperature gMTemp number
	Gui, Add, Text, xp+71 yp+5 w10 h25, C
	
	Gui, Add, CheckBox, xs+10 yp+22 w175 h25 gMDT vdt, DUAL TRANSDUCER
	Gui, Add, CheckBox, yp+25 w175 h25 gMDR vdr, DUAL REDUNDANT
	Gui, Add, CheckBox, yp+25 w175 h25 vfeed gMFeedthru, FEEDTHRU
	
	Gui, Add, Text, xs+10 y360 w130 h25, CV SIZE
	Gui, Add, DropDownList, xp+107 yp-5 w65 h25 R3 gMCVSize vCVSize, 1/4|3/8|1/2
	Gui, Add, Text, xp+70 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+27 w130 h25, CRACK PRESS
	Gui, Add, DropDownList, xp+107 yp-5 w58 h25 R2 vCVCrack gMCPressure, 50|500
	Gui, Add, Text, xp+62 yp+5 w20 h25, PSI
	
	Gui, Add, Text, xs+10 yp+27 w130 h25, BURST DISK
	Gui, Add, DropDownList, xp+107 yp-5 w58 h25 R4 vCVBurst gMBurst, N/A|4200|6000
	GuiControl, Choose, ComboBox9, 1
	Gui, Add, Text, xp+62 yp+5 w20 h25, PSI
	
	Gui, Add, Text, xs+10 yp+27 w130 h25, CV CONFIG
	Gui, Add, DropDownList, xp+107 yp-5 w85 h25 R4 vCVConfig gMCVConfig, SINGLE|DUAL|TRIPLE
	
	Gui, Add, Button, xs ys+245 w105 h25 Section disabled, BOM BUILDER
	Gui, Add, Button, xs+105 ys w105 h25 disabled, MANDRELS
	Gui, Add, Button, xs ys+30 w70 h25 gClicker disabled, 9290-6000
	Gui, Add, Button, xs+70 ys+30 w70 h25 gClicker disabled, 9293-6000
	Gui, Add, Button, xs+140 ys+30 w70 h25 gClicker disabled, 9290-2000
	
	Gui, Tab, 2
	
	Gui, Font, w700
	Gui, Add, GroupBox, x5 y30 w210 h50 Section, OPTIONS
	
	Gui, Font, w400
	Gui, Add, Radio, xs+10 ys+20 w75 h25 vRadioPart gRPart, PART
	Gui, Add, Radio, xp+80 yp w100 h25 vRadioDrawing gRDrawing, DRAWING
	
	Gui, Font, w700
	Gui, Add, GroupBox, xs ys+55 w210 h335 Section, CLAMP PROPERTIES

	Gui, Font, s11 cblack w400
	Gui, Add, Text, xs+10 ys+30 w75 h25, CLAMP
	Gui, Add, DropDownList, xp+80 yp-5 w110 h25 R13 vClamp gClamp, BYPASS|MANDREL|CHEMICAL
	
	Gui, Add, Text, xs+10 yp+32 w100 h25, TYPE
	Gui, Add, DropDownList, xp+80 yp-5 w110 h25 r10 vClampType gCType
	
	Gui, Add, Text, xs+10 yp+32 w100 h25, LENGTH
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vCLength gCLength
	Gui, Add, Text, xp+87 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+28 w100 h25, WIDTH
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vCWidth gCWidth
	Gui, Add, Text, xp+87 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+28 w100 h25, HEIGHT
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vCHeight gCHeight
	Gui, Add, Text, xp+87 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+28 w100 h25, POCKET
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vCPocket gCPocket
	Gui, Add, Text, xp+87 yp+5 w15 h25, IN
	
	Gui, Add, Text, xs+10 yp+28 w100 h25, MATERIAL
	
	;_______________________________________________________________________
	; 		ACCOUNT FOR POSSIBILITY OF %MATERIALNUM% BEING 0 & CAUSING ERROR
	;
		if (MaterialNum < 1)
			row3option := ""
		else
			row3option := "r" MaterialNum
		
	Gui, Add, ComboBox, xp+80 yp-5 w110 h25 %row3option% vCMaterial Uppercase gCMaterial, %TheMaterials%
	
	Gui, Add, Text, xs+10 yp+32 w75 h25, YIELD
	Gui, Add, Edit, xp+80 yp-5 w75 h25 vCYield number gCYield
	Gui, Add, Text, xp+88 yp+5 w10 h25, K
	
	Gui, Add, Text, xs+10 yp+28 w75 h25, DRAWING
	Gui, Add, Edit, xp+80 yp-5 w110 h25 vCDrawing gCDrawing
	
	Gui, Add, Text, xs+10 yp+33 w120 h25, MATERIAL CODE
	Gui, Add, Edit, xp+140 yp-5 w50 h25 vCCode Uppercase gCCode
	
	Gui, Add, Text, xs+10 yp+33 w75 h25, CV CONFIG
	Gui, Add, DropDownList, xp+80 yp-5 w110 h25 r10 vCCVConfig gCCVConfig, SINGLE|DUAL|TRIPLE
		
	Gui, Font, w700
	Gui, Add, GroupBox, xs yp+40 w210 h60, PART NUMBER
	Gui, Font, w400
	Gui, Add, Text, xs+10 yp+30 w75 h25, PART #
	Gui, Add, edit, xp+80 yp-5 w110 h25 vCPartNum gCPartNum
	
	Gui, Add, Button, xs+10 yp+40 w90 h25 disabled gCTitle, TITLE IT
	Gui, Add, Button, xp+100 yp w90 h25 disabled, EZ CLAMPS

;___________________________________________________________________________
;__________SHOW/HIDE GUI CONTROLS________________________________________

	GuiControl, Hide, Static18
	GuiControl, Hide, Static19
	GuiControl, Hide, Static20
	GuiControl, Hide, Static21
	GuiControl, Hide, Static22
	GuiControl, Hide, Static23
	GuiControl, Hide, Static24
	GuiControl, Hide, ComboBox7
	GuiControl, Hide, ComboBox8
	GuiControl, Hide, ComboBox9
	GuiControl, Hide, ComboBox10
	GuiControl, Disable, ComboBox5

	;~ If (xposition > LeftMon)
		;~ Xpos := RightMonC - (GuiWidth/2)
	;~ else
		;~ Xpos := LeftMonC - (GuiWidth/2)
	
;____________________________________________________________________________
;__________GUI SHOW________________________________________________________

	Gui, Show, w%GuiWidth% h%GuiHeight%, Titler %Titler_Version%
	SendInput, {blind}{right}
	Return
	
	
;_____________________________________________________________________________________________________________
;____________________________________________G LABELS FOR GUI________________________________________________
	
	TheTab:
		TabClick(LastTab, tGuiHeight, ClampTabH, cGuiHeight, cTabH, GuiHeight, TabH)
		SubmitCheck()
	return
	
	MPartNum:
		SubmitCheck()
		guicontrolget, texts,, Edit1
		if (texts = "JEFF")
			MEnableAll()
	return
	
	MDiameter:
		SubmitCheck()
	return
	
	MWeight:
		SubmitCheck()
	return
	
	MThreads:
		AutoComplete(A_GuiControl)
		SubmitCheck()
	return
	
	MProfile:
		SubmitCheck()
	return
	
	MMaterial:
		AutoComplete(A_GuiControl)
		SubmitCheck()
	return
	
	MYield:
		SubmitCheck()
	return
	
	MByPass:
		SubmitCheck()
	return
	
	MDMS:
		NoChemCheck()
		SubmitCheck()
	return
	
	MCoupling:
		NoChemCheck()
		SubmitCheck()
	return
	
	MFlowMeter:
		NoChemCheck()
		SubmitCheck()
	return
	
	MChem:
		ChemInjCheck(cChemY, cGroup1H, cGroup2Y, cGroup2H, cTabH, cBomY, cMandrelY, c96Y, c93Y, c92Y, cGuiHeight, ChemY, Group1H, Group2Y, Group2H, TabH, BomY, MandrelY, 96Y, 93Y, 92Y, GuiHeight)
		SubmitCheck()
	return
	
	MGFamily:
		ROCCheck()
		SubmitCheck()
	return
	
	MGDiameter:
		SubmitCheck()
	return
	
	MGType:
		SubmitCheck()
	return
	
	MPressure:
		SubmitCheck()
	return
	
	MTemp:
		SubmitCheck()
	return
	
	MDT:
		DualsCheck()
		SubmitCheck()
	return
	
	MDR:
		DualsCheck()
		SubmitCheck()
	return
	
	MFeedthru:
		SubmitCheck()
	return
	
	MCVSize:
		CVSizeCheck()
		SubmitCheck()
	return
	
	MCPressure:
		SubmitCheck()
	return
	
	MBurst:
		SubmitCheck()
	return
	
	MCVConfig:
		SubmitCheck()
	return
	
	RPart:
		PartDrawing(PDrawingY, DDrawingY, PGroupC2H, DGroupC2H, ClampTabH, GuiDrawingH, PButtonY, DButtonY)
		CSubmitCheck()
	return
	
	RDrawing:
		PartDrawing(PDrawingY, DDrawingY, PGroupC2H, DGroupC2H, ClampTabH, GuiDrawingH, PButtonY, DButtonY)
		CSubmitCheck()
	return
	
	Clamp:
		ClampChange()
	return
	
	CType:
		CSubmitCheck()
	return
	
	CLength:
		CSubmitCheck()
	return
	
	CWidth:
		CSubmitCheck()
	return
	
	CHeight:
		CSubmitCheck()
	return
	
	CPocket:
		CSubmitCheck()
	return
	
	CMaterial:
		AutoComplete(A_GuiControl)
		CSubmitCheck()
	return
	
	CYield:
		CSubmitCheck()
	return
	
	CDrawing:
		CSubmitCheck()
	return
	
	CCode:
		CSubmitCheck()
	return
	
	CCVConfig:
		CSubmitCheck()
	return
	
	CPartNum:
		CSubmitCheck()
	return

;_____________________________________________________________________________________________________________
;______________________________________________ AUTOCOMPLETE______________________________________________

AutoComplete(CTRL) 
{ 
   static lf = "`n" 
   If GetKeyState("Delete") or GetKeyState("Backspace") 
      Return 
   SetControlDelay, -1 
   SetWinDelay, -1 
   GuiControlGet, h, Hwnd, %CTRL% 
   ControlGet, haystack, List, , , ahk_id %h% 
   GuiControlGet, needle, , %CTRL% 
   StringMid, text, haystack, pos := InStr(lf . haystack, lf . needle) 
      , InStr(haystack . lf, lf, false, pos) - pos 
   If text !=
   {
      if pos != 0
      { 
         ControlSetText, , %text%, ahk_id %h% 
         ControlSend, , % "{Right " . StrLen(needle) . "}+^{End}", ahk_id %h% 
      } 
   }
} 

;_____________________________________________________________________________________________________________
;______________________________________________ TAB CLICK_____________________________________________________
	
	TabClick(LastTab, tGuiHeight, ClampTabH, cGuiHeight, cTabH, GuiHeight, TabH)
	{
		if (LastTab = "MANDREL")
		{
			Gui, Show, h%tGuiHeight%
			GuiControl, MoveDraw, SysTabControl321, h%ClampTabH%
			GuiControl,, Button21, 1
			GuiControl, Disable, Edit16
		}
		else
		{
			GuiControlGet, ChemCheck,, Button10
			if ChemCheck
			{
				Gui, Show, h%cGuiHeight%
				GuiControl, MoveDraw, SysTabControl321, h%cTabH%
			}
			else
			{
				Gui, Show, h%GuiHeight%
				GuiControl, MoveDraw, SysTabControl321, h%TabH%
			}
		}
	}
	
	
	
;_____________________________________________________________________________________________________________
;______________________________________________ CHEM INJ CHECK ______________________________________________
	
	ChemInjCheck(cChemY, cGroup1H, cGroup2Y, cGroup2H, cTabH, cBomY, cMandrelY, c96Y, c93Y, c92Y, cGuiHeight, ChemY, Group1H, Group2Y, Group2H, TabH, BomY, MandrelY, 96Y, 93Y, 92Y, GuiHeight)
	{
		GuiControlGet, ChemCheck,, Button10
		;GAUGE
		GuiControl, % ChemCheck ? "Hide" : "Show", Static10
		GuiControl, % ChemCheck ? "Hide" : "Show", Static11
		GuiControl, % ChemCheck ? "Hide" : "Show", Static12
		GuiControl, % ChemCheck ? "Hide" : "Show", Static13
		GuiControl, % ChemCheck ? "Hide" : "Show", Static14
		GuiControl, % ChemCheck ? "Hide" : "Show", Static15
		GuiControl, % ChemCheck ? "Hide" : "Show", Static16
		GuiControl, % ChemCheck ? "Hide" : "Show", Static17
		GuiControl, % ChemCheck ? "Hide" : "Show", ComboBox4
		GuiControl, % ChemCheck ? "Hide" : "Show", ComboBox5
		GuiControl, % ChemCheck ? "Hide" : "Show", ComboBox6
		GuiControl, % ChemCheck ? "Hide" : "Show", Button7
		GuiControl, % ChemCheck ? "Hide" : "Show", Button8
		GuiControl, % ChemCheck ? "Hide" : "Show", Button9
		GuiControl, % ChemCheck ? "Hide" : "Show", Button12
		GuiControl, % ChemCheck ? "Hide" : "Show", Button13
		GuiControl, % ChemCheck ? "Hide" : "Show", Button14
		GuiControl, % ChemCheck ? "Hide" : "Show", Edit6
		GuiControl, % ChemCheck ? "Hide" : "Show", Edit7
		
		if (ChemCheck)
			GuiControl, Text, Edit7, 
		
		;CHEM
		GuiControl, % ChemCheck ? "Show" : "Hide", Static18
		GuiControl, % ChemCheck ? "Show" : "Hide", Static19
		GuiControl, % ChemCheck ? "Show" : "Hide", Static20
		GuiControl, % ChemCheck ? "Show" : "Hide", Static21
		GuiControl, % ChemCheck ? "Show" : "Hide", Static22
		GuiControl, % ChemCheck ? "Show" : "Hide", Static23
		GuiControl, % ChemCheck ? "Show" : "Hide", Static24
		GuiControl, % ChemCheck ? "Show" : "Hide", ComboBox7
		GuiControl, % ChemCheck ? "Show" : "Hide", ComboBox8
		GuiControl, % ChemCheck ? "Show" : "Hide", ComboBox9
		GuiControl, % ChemCheck ? "Show" : "Hide", ComboBox10
		GuiControl,, ComboBox7, % ChemCheck ? "|1/4|3/8|1/2" : "|1/4|3/8|1/2||"
		
		GuiControl, text, Button11, % ChemCheck ? "CV PROPERTIES" : "GAUGE PROPERTIES"

		GuiControl, MoveDraw, Button10 , % "y" (ChemCheck ? cChemY : ChemY)
		GuiControl, MoveDraw, Button1, % "h" (ChemCheck ? cGroup1H : Group1H)
		GuiControl, MoveDraw, Button11, % "y" (ChemCheck ? cGroup2Y : Group2Y)
		GuiControl, MoveDraw, Button11, % "h" (ChemCheck ? cGroup2H : Group2H)
		GuiControl, MoveDraw, SysTabControl321, % "h" (ChemCheck ? cTabH : TabH)
		GuiControl, MoveDraw, Button15, % "y" (ChemCheck ? cBomY : BomY)
		GuiControl, MoveDraw, Button16, % "y" (ChemCheck ? cMandrelY : MandrelY)
		GuiControl, MoveDraw, Button17, % "y" (ChemCheck ? c96Y : 96Y)
		GuiControl, MoveDraw, Button18, % "y" (ChemCheck ? c93Y : 93Y)
		GuiControl, MoveDraw, Button19, % "y" (ChemCheck ? c92Y : 92Y)
		Gui, Show, % "h" (ChemCheck ? cGuiHeight : GuiHeight)
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________PART OR DRAWING_______________________________________________
		
	PartDrawing(PDrawingY, DDrawingY, PGroupC2H, DGroupC2H, ClampTabH, GuiDrawingH, PButtonY, DButtonY)
	{
		GuiControlGet, RPart,, Button21
		GuiControl, % RPart ? "Show" : "Hide", Static35
		GuiControl, % RPart ? "Show" : "Hide", Static36
		GuiControl, % RPart ? "Show" : "Hide", Static37
		GuiControl, % RPart ? "Show" : "Hide", Static39
		GuiControl, % RPart ? "Show" : "Hide", Static40
		GuiControl, % RPart ? "Show" : "Hide", Button24
		GuiControl, % RPart ? "Show" : "Hide", ComboBox13
		GuiControl, % RPart ? "Show" : "Hide", Edit13
		GuiControl, % RPart ? "Show" : "Hide", Edit15
		GuiControl, % RPart ? "Show" : "Hide", Edit16

		GuiControl, MoveDraw, Static38, % "y" (RPart ? PDrawingY+5 : DDrawingY+5)
		GuiControl, MoveDraw, Edit14, % "y" (RPart ? PDrawingY : DDrawingY)
		GuiControl, MoveDraw, Button23, % "h" (RPart ? PGroupC2H : DGroupC2H)
		GuiControl, MoveDraw, SysTabControl321, % "h" (RPart ? ClampTabH : GuiDrawingH)
		GuiControl, MoveDraw, Button25, % "y" (RPart ? PButtonY : DButtonY)
		GuiControl, MoveDraw, Button26, % "y" (RPart ? PButtonY : DButtonY)
		Gui, Show, % "h" (RPart ? ClampTabH : GuiDrawingH)
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________NO CHEM CHECK________________________________________________
	
	NoChemCheck()
	{
		GuiControlGet, NoChemCheck1,, Button7
		GuiControlGet, NoChemCheck2,, Button8
		GuiControlGet, NoChemCheck3,, Button9
		GuiControl, % NoChemCheck1 or NoChemCheck2 or NoChemCheck3 ? "Disable" : "Enable", Button10
		SubmitCheck()
	}
	
;_____________________________________________________________________________________________________________
;______________________________________________ ROC CHECK ____________________________________________________

	RocCheck()
	{
		GuiControlGet, RocText,, ComboBox4
		GuiControl, % RocText = "ROC" ? "Enable" : "Disable", ComboBox5
		SubmitCheck()
	}
	
;_____________________________________________________________________________________________________________
;______________________________________________ DUALS CHECK _________________________________________________
	
	DualsCheck()
	{
		GuiControlGet, Duals12,, Button12
		GuiControlGet, Duals13,, Button13
		GuiControl, % Duals12 ? "Disable" : "Enable", Button13
		GuiControl, % Duals13 ? "Disable" : "Enable", Button12
		SubmitCheck()
	}
	
;_____________________________________________________________________________________________________________
;________________________________________________ SUBMIT CHECK_______________________________________________
	
	SubmitCheck()
	{
		loop, 10
			GuiControlGet, Combos%A_Index%,, Combobox%A_Index%
		loop, 7
			GuiControlGet, Edits%A_Index%,, Edit%A_Index%
		loop, 14
			GuiControlGet, Butts%A_Index%,, Button%A_Index%
		
		;MINIMUM REQUIREMENTS 1
		If (Combos1 <> "" and Combos2 <> "" and Combos3 <> "" and StrLen(Edits1) > 8 and Edits2 <> "" and Edits5 <> "")
		{
			;MINIMUM REQUIREMENTS 2
			If (Butts3 or Butts4 or Butts5)
			{
				;ROC GAUGE MANDREL
				If (!Button10 and Combos4 = "ROC" and Combos6 <> "" and Edits6 <> "" and Edits7 <> "")
				{
					If (Combos5 <> "")
					{
						MEnableAll()
						return
					}
				}
				;NON ROC GAUGE MANDREL
				else if (!Button10 and Combos4 <> "" and Combos4 <> "ROC" and Combos6 <> "" and Edits6 <> "" and Edits7 <> "")
				{
					MEnableAll()
					return
				}
				;CHEMICAL INJECTION
				else if (Combos7 <> "" and Combos8 <> "" and Combos9 <> "" and Combos10 <> "")
				{
					MEnableAll()
					return
				}
			}
		}
			MDisableAll()
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________CLAMP SUBMIT CHECK___________________________________________

	CSubmitCheck()
	{
		loop, 14
			GuiControlGet, Combos%A_Index%,, Combobox%A_Index%
		loop, 15
			GuiControlGet, Edits%A_Index%,, Edit%A_Index%
		GuiControlGet, PorD,, Button21
		
		;DRAWING
		if (!PorD and Combos11 <> "" and Combos12 <>"" and Edits8 <> "" and Edits9 <> "" and Edits10 <> "" and Edits11 <> "" and StrLen(Edits14) = 9)
		{
			CEnableAll()
		}
		
		;PART
		else if (PorD and Combos11 <> "" and Combos12 <> "" and Edits8 <> "" and Edits9 <> "" and Edits10 <> "" and Edits11 <> "" and StrLen(Edits14) = 9 and Combos13 <> "" and Edits13 <> "" and StrLen(Edits15) = 2 and Combos14 <> "")
		{
			CEnableAll()
		}
		
		;NONE
		else
			CDisableAll()

		GuiControl, text, Edit16, % (StrLen(Edits14) = 9 and StrLen(Edits15) = 2) ? Edits14 . "-" . Edits15 : ""
	}

;_____________________________________________________________________________________________________________
;_____________________________________________MANDREL ENABLE ALL___________________________________________
	
	MEnableAll()
	{
		GuiControl, Enable, Button15
		GuiControl, Enable, Button16
		GuiControl, Enable, Button17
		GuiControl, Enable, Button18
		GuiControl, Enable, Button19
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________MANDREL DISABLE ALL___________________________________________
	
	MDisableAll()
	{
		GuiControl, Disable, Button15
		GuiControl, Disable, Button16
		GuiControl, Disable, Button17
		GuiControl, Disable, Button18
		GuiControl, Disable, Button19
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________CLAMP ENABLE ALL______________________________________________
	
	CEnableAll()
	{
		GuiControl, Enable, Button25
		GuiControl, Enable, Button26
	}
	
;_____________________________________________________________________________________________________________
;_____________________________________________CLAMP DISABLE ALL___________________________________________
	
	CDisableAll()
	{
		GuiControl, Disable, Button25
		GuiControl, Disable, Button26
	}
	
;_____________________________________________________________________________________________________________
;______________________________________________ CVSize Check _________________________________________________

	CVSizeCheck()
	{
		GuiControlGet, texts,, ComboBox7
		GuiControl,, Combobox8, % texts = "3/8" ? "|50|500" : texts = "1/2" or texts = "1/4" ? "|50" : break
	}

;_____________________________________________________________________________________________________________
;______________________________________________ Material Setting______________________________________________

	MaterialSetting(Material)
	{
		;1 CHROME
			Material := InStr(Material, "1CR") = 0 ? Material : "1% CHROME"
			Material := InStr(Material, "1 CR") = 0 ? Material : "1% CHROME"
			Material := InStr(Material, "1CHROME") = 0 ? Material : "1% CHROME"
			Material := InStr(Material, "1 CHROME") = 0 ? Material : "1% CHROME"
			Material := InStr(Material, "1%CHROME") = 0 ? Material : "1% CHROME"
			
		;9 CHROME
			Material := InStr(Material, "9CR") = 0 ? Material : "9% CHROME"
			Material := InStr(Material, "9 CR") = 0 ? Material : "9% CHROME"
			Material := InStr(Material, "9CHROME") = 0 ? Material : "9% CHROME"
			Material := InStr(Material, "9 CHROME") = 0 ? Material : "9% CHROME"
			Material := InStr(Material, "9%CHROME") = 0 ? Material : "9% CHROME"

		;13 CHROME
			Material := InStr(Material, "13CR") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			Material := InStr(Material, "13 CR") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			Material := InStr(Material, "13CHROME") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			Material := InStr(Material, "13 CHROME") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			Material := InStr(Material, "13% CHROME") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			Material := InStr(Material, "13%CHROME") = 0 ? Material : InStr(Material, "S") <> 0 ? "SUPER 13`% CHROME" : "13`% CHROME"
			
		;22 CHROME
			Material := InStr(Material, "22CR") = 0 ? Material : "22% CHROME"
			Material := InStr(Material, "22 CR") = 0 ? Material : "22% CHROME"
			Material := InStr(Material, "22CHROME") = 0 ? Material : "22% CHROME"
			Material := InStr(Material, "22 CHROME") = 0 ? Material : "22% CHROME"
			Material := InStr(Material, "22%CHROME") = 0 ? Material : "22% CHROME"
				
		;25 CHROME
			Material := InStr(Material, "25CR") = 0 ? Material : "25% CHROME"
			Material := InStr(Material, "25 CR") = 0 ? Material : "25% CHROME"
			Material := InStr(Material, "25CHROME") = 0 ? Material : "25% CHROME"
			Material := InStr(Material, "25 CHROME") = 0 ? Material : "25% CHROME"
			Material := InStr(Material, "25%CHROME") = 0 ? Material : "25% CHROME"
			
		;420MOD
			Material := InStr(Material, "MOD") <> 0 ? 13`% CHROME : Material
			
		;MP-35-N
			Material := InStr(Material, 35) <> 0 ? "MP-35-N" : Material
			
		;316 STAINLESS STEEL
			Material := InStr(Material, "316") = 0 ? Material : InStr(Material, "316L") = 0 ? "316 STAINLESS STEEL" : "316L STAINLESS STEEL"
			
		;4140 LOW ALLOY STEEL
			Material := InStr(Material, "4140") = 0 ? Material : "4140 LOW ALLOY STEEL"
			
		;4130 LOW ALLOY STEEL
			Material := InStr(Material, "4130") = 0 ? Material : "4130 LOW ALLOY STEEL"
			
		;NICKEL ALLOY 718
			Material := InStr(Material, "718") = 0 ? Material : "NICKEL ALLOY 718"
			
		;NICKEL ALLOY 925
			Material := InStr(Material, "925") = 0 ? Material : "NICKEL ALLOY 925"
			
		return Material
	}

;_____________________________________________________________________________________________________________
;______________________________________________ TITLE FORMATING_______________________________________________

	FormatTitle(ByRef PartNum, ByRef MandrelDiameter, ByRef Weight, ByRef ThreadType, ByRef BxP, ByRef BxB, ByRef PxP, ByRef Material, ByRef Yield, ByRef ByPass, ByRef Term, ByRef Coupling, ByRef FlowMeter, ByRef ChemInj, ByRef GaugeFamily, ByRef GaugeDiameter, ByRef GaugeType, ByRef Pressure, ByRef Temperature, ByRef Dt, ByRef Dr, ByRef Feed, ByRef CVSize, ByRef CVCrack, ByRef CVBurst, ByRef CVConfig, ByRef Profile, ByRef Feat1, ByRef Feat2, ByRef Feat3, ByRef Termination)
	{
		global
		PartNum := PartNum
		MandrelDiameter := MandrelDiameter
		Weight := Round(Weight, 2)
		Weight := Weight
		ThreadType := ThreadType
		Profile1 := BxP ? "BOX" : BxB ? "BOX" : PxP ? "PIN" : ""
		Profile2 := BxP ? "PIN" : BxB ? "BOX" : PxP ? "PIN" : ""
		Material := Material
		Yield := Yield "K"
		ByPass := Bypass ? ", BYPASS" : ""
		Termination := term ? "DUAL METAL SEAL CABLE TERMINATION" : "SINGLE METAL SEAL CABLE TERMINATION"
		Coupling := Coupling ? "COUPLING" : ""
		Flowmeter := Flowmeter ? "FLOWMETER" : ""
		GaugeFamily := GaugeFamily
		GaugeDiameter := GaugeDiameter <> "" ? GaugeDiameter " OD" : ""
		GaugeType := GaugeType
		Pressure := Pressure "K"
		Temperature := Temperature "C"
		Feat1 := Dt ? "DUAL TRANSDUCERS, " : ""
		Feat2 := Dr ? "DUAL REDUNDANT, " : ""
		Feat3 := Feed ? "FEEDTHRU, " : ""
		CVSize := CVSize <> "" ? CVSize " CHECK VALVE" : ""
		CVCrack := CVCrack <> "" ? ", " CVCrack " PSI CRACKING PRESSURE" : ""
		CVBurst := CVBurst = "" ? "," : CVBurst = "N/A" ? "" : ", " CVBurst " PSI BURST DISK"
		CVConfig := CVConfig
	}

;_____________________________________________________________________________________________________________
;______________________________________________ TITLE FORMATING_______________________________________________

	CFormatTitle(ByRef Clamp, ByRef ClampType, ByRef CLength, ByRef CWidth, ByRef CHeight, ByRef CPocket, ByRef CMaterial, ByRef CYield, ByRef CDrawing, ByRef CCode, ByRef CPartNum, ByRef CCVConfig)
	{
		Clamp := Clamp . " CLAMP"
		ClampType := ClampType
		CLength := Round(CLength, 2) . "L"
		CWidth := Round(CWidth, 2) . "W"
		CHeight := Round(CHeight, 2) . "H"
		CPocket := Round(CPocket, 2) . " CV POCKET"
		CMaterial := CMaterial
		CYield := CYield . "K"
		CDrawing := CDrawing
		CCode := CCode
		CPartNum := CPartNum
		CCVConfig := CCVConfig
	}
;_____________________________________________________________________________________________________________
;__________________________________________ MANDREL GUI SUBMIT ______________________________________________

	Clicker:
	
		;-------------------------------------------
		;			GUI SUBMIT
		;-------------------------------------------
		
		Gui, Submit, NoHide
			
		;-------------------------------------------
		;			MATERIAL SETTING
		;-------------------------------------------

		Material := MaterialSetting(Material)

		;-------------------------------------------
		;			FORMAT VARIABLES
		;-------------------------------------------
		
		FormatTitle(PartNum, MandrelDiameter, Weight, ThreadType, BxP, BxB, PxP, Material, Yield, ByPass, Term, Coupling, FlowMeter, ChemInj, GaugeFamily, GaugeDiameter, GaugeType, Pressure, Temperature, Dt, Dr, Feed, CVSize, CVCrack, CVBurst, CVConfig, Profile, Feat1, Feat2, Feat3, Termination)
		
		;-------------------------------------------
		;			MAKE TITLE
		;-------------------------------------------
		
		;9290-6000 LEVEL CLICK
		;===================
		If (A_GuiControl = "9290-6000")
		{
			;~~~~~~~~~~~~~~~~~~
			;CHEMICAL INJECTION
			if ChemInj
				96Level := "CHEMICAL INJECTION MANDREL ASSEMBLY, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " CVConfig " " CVSize CVCrack CVBurst ", " Material " " Yield Bypass Coupling
			
			;~~~~~~~~~
			;FLOWMETER
			else if Flowmeter
				96Level := "FLOWMETER GAUGE MANDREL ASSEMBLY, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Pressure " " Temperature ", " Material " " Yield Bypass ", " Termination Coupling
			
			;~~~~~
			;GAUGE
			else
				96Level := "GAUGE MANDREL ASSEMBLY, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Pressure " " Temperature ", " Material " " Yield Bypass ", " Termination Coupling
			
			Clipboard := 96Level
		}
		
		;9293-6000 LEVEL CLICK
		;=====================
		else if (A_GuiControl = "9293-6000")
		{
			;~~~~~~~~~~~~~~~~~~
			;CHEMICAL INJECTION
			if ChemInj
				93Level := "MANDREL ASSEMBLY, CHEMICAL INJECTION, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " CVConfig " " CVSize ", " Material " " Yield Bypass
			
			;~~~~~~~~~
			;FLOWMETER
			else if Flowmeter
				93Level := "MANDREL ASSEMBLY, FLOWMETER, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Material " " Yield Bypass

			;~~~~~~
			;GAUGE 
			else
				93Level := "MANDREL ASSEMBLY, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Material " " Yield Bypass
			
			Clipboard := 93Level
		}
		
		;9290-2000 LEVEL CLICK
		;===================
		else if(A_GuiControl = "9290-2000")
		{
			;~~~~~~~~~~~~~~~~~~
			;CHEMICAL INJECTION
			if ChemInj
				92Level := "MANDREL, CHEMICAL INJECTION, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " CVConfig " " CVSize ", " Material " " Yield Bypass
			
			;~~~~~~~~~
			;FLOWMETER
			else if Flowmeter
				92Level := "MANDREL, FLOWMETER, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Material " " Yield Bypass
			
			;~~~~~~
			;GAUGE 
			else
				92Level := "MANDREL, " MandrelDiameter " - " Weight " " ThreadType " " Profile1 ", " MandrelDiameter " - " Weight " " ThreadType " " Profile2 ", " GaugeType " " GaugeFamily " " GaugeDiameter ", " Feat1 Feat2 Feat3 Material " " Yield Bypass
			
			Clipboard := 92Level
		}

	;-------------------------------------------
	;			SHOW SPLASH
	;-------------------------------------------
		
	SplashImage,, %Splash%,, The %A_GuiControl% Title has been copied. Paste it where it is needed.`n`n[Click anywhere to close this window],, Arial
	
	keywait, LButton, D

	SplashImage, off
		
	return

;__________________________________________________________________________________________________________
;__________________________________________MANDRELS BUTTON______________________________________________
		
	ButtonMandrels:
	
	;GUI SUBMIT
	Gui, Submit, nohide
	
	;SET YES/NO FIELDS
	DualTran := % Dt ? "Yes" : "No"
	DualRed := % Dr ? "Yes" : "No"
	BPass := % Bypass ? "Yes" : "No"
	FThru :=  % Feed ? "Yes" : "No"
	Weight := Round(Weight, 2)
	Profile := BxP ? "BxP" : BxB ? "BxB" : PxP ? "PxP" :""
	
	;SET VARIABLE GOING TO EXCEL
	if cheminj
		MandrelsInput := PartNum . "," . ThreadType . "," . MandrelDiameter . "," . Weight . "," . Profile . ",Chem Inj," . CVSize . ",---," . CVConfig . ",No,No," . BPass . "," . FThru
	else
		MandrelsInput := PartNum . "," . ThreadType . "," . MandrelDiameter . "," . Weight . "," . Profile . "," . GaugeFamily . "," . Pressure . "," . Temperature . "," . GaugeType . "," . DualTran . "," . DualRed . "," . BPass . "," . FThru
	;~ MsgBox % mandrelsinput
	
	;~ ;RUN MANDRELS.XLSM
	Run, %EPub%\mandrels.xlsm
	
	;~ ;WAIT FOR MANDRELS TO OPEN
	XL := Excel_Get()
	WinActivate, ahk_class XLMAIN
		
	;~ ;ACTIVATE SHEET 1
	XL.Range("Q2000").Activate
	sleep, 500
	
	;~ ;ENTER "MANDRELINPUT" IN CELL Z50
	XL.range("Z50") := MandrelsInput

	return







;_____________________________________________________________________________________________________________
;______________________________________________CLAMP CHANGE________________________________________________
	
	ClampChange()
	{
		GuiControlGet, TheClamp,, ComboBox11
		GuiControl,, ComboBox12, % TheClamp = "BYPASS" ? "|N/A||" : TheClamp = "MANDREL" ? "|CLAMP|DEFLECTOR|RIGHT|LEFT|BLOCK" : "|SINGLE 1/4|SINGLE 3/8|SINGLE 1/2|DUAL 1/4|DUAL 3/8|DUAL1/2"
		GuiControl, % TheClamp = "BYPASS" ? "Disable" : "Enable", Combobox12
		GuiControl,, ComboBox14, % TheClamp = "CHEMICAL" ? "|SINGLE|DUAL|TRIPLE" : "|N/A||"
		GuiControl, % TheClamp = "CHEMICAL" ? "Enable" : "Disable", ComboBox14
		
		GuiControl, Text, Edit11, % TheClamp = "BYPASS" or TheClamp = "MANDREL" ? "N/A" : ""
		GuiControl, % TheClamp = "BYPASS" or TheClamp = "MANDREL" ? "Disable" : "Enable", Edit11
	}
	
;_____________________________________________________________________________________________________________
;______________________________________________CLAMP GUI SUBMIT______________________________________________
	
	CTitle:
	
		;-------------------------------------------
		;			GUI SUBMIT
		;-------------------------------------------
		
		Gui, Submit, NoHide
			
		;------------------------------------------------
		;			MATERIAL SETTING
		;------------------------------------------------
		
		CMaterial := % RadioPart ? MaterialSetting(CMaterial) : CMaterial

		;-------------------------------------------------
		;			FORMAT VARIABLES
		;-------------------------------------------------
		
		CFormatTitle(Clamp, ClampType, CLength, CWidth, CHeight, CPocket, CMaterial, CYield, CDrawing, CCode, CPartNum, CCVConfig)
		
		;-------------------------------------------
		;			MAKE TITLE
		;-------------------------------------------
		
		;PART
		;=======
		If (RadioPart)
		{
			;CHEMICAL PART
			If (Clamp = "CHEMICAL CLAMP")
				CTitle := "PROTECTION CLAMP, " CCVConfig " CHEMICAL INJECTION, " CLength " X " CWidth " X " CHeight ", " CMaterial " " CYield ", " CPocket
			
			;MANDREL PART
			else if (Clamp = "MANDREL CLAMP")
				CTitle := Clamp ", " CLength " X " CWidth " X " CHeight ", " ClampType ", " CMaterial " " CYield
				
			;BYPASS PART
			else if (Clamp = "BYPASS CLAMP")
				CTitle := Clamp ", " CLength " X " CWidth " X " CHeight ", " CMaterial " " CYield

			Clipboard := CTitle
		}
		
		;DRAWING
		;=========
		else
		{
			;CHEMICAL PART
			If (Clamp = "CHEMICAL CLAMP")
				CTitle := "PROTECTION CLAMP, " CCVConfig " CHEMICAL INJECTION, " CLength " X " CWidth " X " CHeight ", " CPocket
			
			;MANDREL PART
			else if (Clamp = "MANDREL CLAMP")
				CTitle := Clamp ", " CLength " X " CWidth " X " CHeight ", " ClampType
				
			;BYPASS PART
			else if (Clamp = "BYPASS CLAMP")
				CTitle := Clamp ", " CLength " X " CWidth " X " CHeight
				
			Clipboard := CTitle
		}
	
	;-------------------------------------------
	;			SHOW SPLASH
	;-------------------------------------------
		
	SplashImage,, %Splash%,, The Clamp Title has been copied. Paste it where it is needed.`n`n[Click anywhere to close this window],, Arial
	
	keywait, LButton, D

	SplashImage, off
		
	return
	
;_____________________________________________________________________________________________________________
;______________________________________________EZ CLAMPS BUTTON_____________________________________________
	
	ButtonEZClamps:
	
	;GUI SUBMIT
	Gui, Submit, nohide
	
	;2 DECIMAL PLACES
	CLength := Round(CLength, 2)
	CWidth := Round(CWidth, 2)
	CHeight := Round(CHeight, 2)
	CPocket := Round(CPocket, 2)
	
	;SET VARIABLE GOING TO EXCEL
	if (Clamp = "BYPASS")
		ClampsInput := Clamp . "," . cPartNum . "," . CLength . "," . CWidth . "," . CHeight . "," . CMaterial . "," . CYield . "," . CDrawing
	else if(Clamp = "MANDREL")
		ClampsInput := Clamp . "," . cPartNum . "," . ClampType . "," . CLength . "," . CWidth . "," . CHeight . "," . CMaterial . "," . CYield . "," . CDrawing
	else if(Clamp = "CHEMICAL")
		ClampsInput := Clamp . "," . cPartNum . "," . ClampType . "," . CLength . "," . CWidth . "," . CHeight . "," . CPocket . "," . CMaterial . "," . CYield . "," . CDrawing
	;~ MsgBox % ClampsInput
	
	;~ ;RUN EZ CLAMPS.XLSM
	Run, %EPub%\EZ Clamps.xlsm
		sleep, 5000
	WinWaitActive, EZ Clamps
		
	;~ ;WAIT FOR MANDRELS TO OPEN
	XL := Excel_Get()
	WinActivate, ahk_class XLMAIN
		
	;~ ;ACTIVATE SHEET 1
	XL.Range("L8").Activate
	sleep, 500
	
	;~ ;ENTER "MANDRELINPUT" IN CELL Z50
	XL.range("L8") := ClampsInput
	
	return
	
;_____________________________________________________________________________________________________________
;______________________________________________ GUI CLOSE/CANCEL_____________________________________________

	Cancel:
	GuiClose:
	ExitApp
	return


;=================================================================
;                            INCLUDE FILES
;=================================================================
	#Include TTL_Excel Functions.ahk
	
	
	